package com.gxa.modules.service.operationsservice.impl;

import com.gxa.common.R;
import com.gxa.modules.mapper.operationsmapper.PnZuHuXinXiMapper;
import com.gxa.modules.pojo.Build;
import com.gxa.modules.pojo.PnXinXiVo;
import com.gxa.modules.service.operationsservice.PnZuHuXinXiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Company
 * @Classname PnZuHuXinXiServiceImpl
 * @Description TODO
 * @Author pn
 * Date 2022-05-10 9:53
 * Version 1.0
 */
@Service
public class PnZuHuXinXiServiceImpl implements PnZuHuXinXiService {
    R r = new R();
    @Autowired(required = false)
    PnZuHuXinXiMapper pnZuHuXinXiMapper;

    @Override
    public R selectZuHuXinXi(String tenantName, String buildName, String roomName, String socialNum, String userName, String phone, int page, int limit) {
        Integer index = (page - 1) * limit;
        List<PnXinXiVo> pnXinXiVoList = pnZuHuXinXiMapper.selectZuHuXinXi(tenantName, buildName, roomName, socialNum, userName, phone, index, limit);
        int count = pnZuHuXinXiMapper.selectZuHuXinXiCount();
        if (pnXinXiVoList != null) {
            r.setCode(200);
            r.setMsg("查询成功");
            r.setData(pnXinXiVoList);
            r.setCount(count);
        }
        return r;
    }

    @Override
    public R selectBuild() {
        List<Build> buildList = pnZuHuXinXiMapper.selectBuild();
        if (buildList != null){
            r.setCode(200);
            r.setData(buildList);
            r.setMsg("查询成功");
        }
        return r;
    }

    @Override
    public R deleteByIds(String ids) {
        int i = pnZuHuXinXiMapper.deleteByIds(ids);
        if (i > 0){
            r.setCode(200);
            r.setMsg("删除成功");
        }
        return r;
    }
}
